package com.rerijaapps.preguntaloquequieras.adaptadores;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import com.rerijaapps.preguntaloquequieras.R;
import com.rerijaapps.preguntaloquequieras.data.PreguntaData;

import java.util.ArrayList;

public class preguntas_adapter extends BaseAdapter {

    private Context _context;
    private ArrayList<PreguntaData> _data;

    public preguntas_adapter(Context context, ArrayList<PreguntaData> data){
        this._context = context;
        this._data = data;
    }

    @Override
    public int getCount() {
        if(_data != null)
            return _data.size();
        return 0;
    }

    @Override
    public Object getItem(int position) {
        if (_data != null && position < _data.size())
            return _data.get(position);
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {

        View v = convertView;

        if(convertView == null){
            LayoutInflater inflater = (LayoutInflater) _context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = v = inflater.inflate(R.layout.layout_list_preguntas, null);
        }


        // Set Animations
        v.findViewById(R.id.lp_relative).startAnimation(AnimationUtils.loadAnimation(_context, R.anim.fade_in));

        return v;

    }
}
